package Controller;

import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.Session;
import org.zkoss.zk.ui.select.SelectorComposer;
import org.zkoss.zul.Div;
/**
 * 
 * Looks, whether a user is logged in. When not, then the user is redirected to the login page
 * 
 * @author Rupert
 *
 */
public class LoginDenyController extends SelectorComposer<Div>  {
	
	
	public void doAfterCompose(Div comp) throws Exception{
		super.doAfterCompose(comp);
		
		Session session = Executions.getCurrent().getSession();	
		if(!UserCredentialManager.getInstance(session).isAuthenticated()){
			System.out.println("ERST EINLOGGEN!");
			Executions.sendRedirect("login.zul");
		}
	}
}
